<!--
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author lzw
-->
<template>
  <div>
    <BasicTable @register="registerTable">
      <template #tableTitle>
        <Icon :icon="getTitle.icon" class="m-1 pr-1" />
        <span> {{ getTitle.value }} </span>
      </template>
      <template #toolbar>
        <a-button type="default" @click="handleExport()">
          <Icon icon="i-ant-design:download-outlined" /> {{ t('导出') }}
        </a-button>
        <a-button type="default" @click="handleImport()">
          <Icon icon="i-ant-design:upload-outlined" /> {{ t('导入') }}
        </a-button>
        <a-button type="primary" @click="handleForm({})" v-auth="'operating:ftdsHjdssyydj:edit'">
          <Icon icon="i-fluent:add-12-filled" /> {{ t('新增') }}
        </a-button>
      </template>
      <template #firstColumn="{ record }">
        <a @click="handleForm({ id: record.id })">
          {{ record.hjdssyydjZf }}
        </a>
      </template>
    </BasicTable>
    <InputForm @register="registerDrawer" @success="handleSuccess" />
    <FormImport @register="registerImportModal" @success="handleSuccess" />
  </div>
</template>
<script lang="ts" setup name="ViewsOperatingFtdsHjdssyydjList">
  import { unref } from 'vue';
  import { useI18n } from '/@/hooks/web/useI18n';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { useGlobSetting } from '/@/hooks/setting';
  import { downloadByUrl } from '/@/utils/file/download';
  import { router } from '/@/router';
  import { Icon } from '/@/components/Icon';
  import { BasicTable, BasicColumn, useTable } from '/@/components/Table';
  import { ftdsHjdssyydjDelete, ftdsHjdssyydjListData } from '/@/api/operating/ftdsHjdssyydj';
  import { useDrawer } from '/@/components/Drawer';
  import { useModal } from '/@/components/Modal';
  import { FormProps } from '/@/components/Form';
  import InputForm from './form.vue';
  import FormImport from './formImport.vue';

  const { t } = useI18n('operating.ftdsHjdssyydj');
  const { showMessage } = useMessage();
  const { meta } = unref(router.currentRoute);

  const getTitle = {
    icon: meta.icon || 'i-ant-design:book-outlined',
    value: meta.title || t('户籍地诉讼运营登记管理'),
  };

  const searchForm: FormProps = {
    baseColProps: { lg: 6, md: 8 },
    labelWidth: 90,
    schemas: [
      {
        label: t('资方'),
        field: 'hjdssyydjZf',
        component: 'Input',
      },
      {
        label: t('诉讼主体 '),
        field: 'hjdssyydjSsztyg',
        component: 'Input',
      },
      {
        label: t('订单号'),
        field: 'hjdssyydjDdh',
        component: 'Input',
      },
      {
        label: t('客户姓名'),
        field: 'hjdssyydjKhxm',
        component: 'Input',
      },
      {
        label: t('身份证号'),
        field: 'hjdssyydjSfzh',
        component: 'Input',
      },
      {
        label: t('手机号'),
        field: 'hjdssyydjSjh',
        component: 'Input',
      },
      {
        label: t('省份'),
        field: 'hjdssyydjSf',
        component: 'Input',
      },
      {
        label: t('身份证地址'),
        field: 'hjdssyydjSfzdz',
        component: 'Input',
      },
      {
        label: t('剩余本金'),
        field: 'hjdssyydjSybj',
        component: 'Input',
      },
      {
        label: t('诉请金额'),
        field: 'hjdssyydjSqje',
        component: 'Input',
      },
      {
        label: t('管辖法院'),
        field: 'hjdssyydjGxfy',
        component: 'Input',
      },
      {
        label: t('提交日期'),
        field: 'hjdssyydjTjrq',
        component: 'Input',
      },
      {
        label: t('微法院状态'),
        field: 'hjdssyydjWfyzt',
        component: 'Input',
      },
      {
        label: t('法院审批意见'),
        field: 'hjdssyydjFyspyj',
        component: 'Input',
      },
      {
        label: t('法院审核 意见归类'),
        field: 'hjdssyydjFyshyjgl',
        component: 'Input',
      },
      {
        label: t('法院案件沟通情况'),
        field: 'hjdssyydjFyajgtqk',
        component: 'Input',
      },
      {
        label: t('立案方式'),
        field: 'hjdssyydjLafs',
        component: 'Input',
      },
      {
        label: t('材料是否邮寄'),
        field: 'hjdssyydjClsfyj',
        component: 'Input',
      },
      {
        label: t('单号'),
        field: 'hjdssyydjDh',
        component: 'Input',
      },
      {
        label: t('邮寄时间'),
        field: 'hjdssyydjYjsj',
        component: 'Input',
      },
      {
        label: t('法院电话'),
        field: 'hjdssyydjFydh',
        component: 'Input',
      },
      {
        label: t('案件当前状态'),
        field: 'hjdssyydjAjdqzt',
        component: 'Input',
      },
      {
        label: t('法院跟进记录'),
        field: 'hjdssyydjFygjjl',
        component: 'Input',
      },
      {
        label: t('被告手机号状态'),
        field: 'hjdssyydjBgsjhzt',
        component: 'Input',
      },
      {
        label: t('还款意向'),
        field: 'hjdssyydjHkyx',
        component: 'Input',
      },
      {
        label: t('被告跟进记录'),
        field: 'hjdssyydjBggjjl',
        component: 'Input',
      },
      {
        label: t('案件负责人'),
        field: 'hjdssyydjAjfzr',
        component: 'Input',
      },
    ],
  };

  const tableColumns: BasicColumn[] = [
    {
      title: t('资方'),
      dataIndex: 'hjdssyydjZf',
      key: 'a.hjdssyydj_zf',
      sorter: true,
      width: 230,
      align: 'left',
      slot: 'firstColumn',
    },
    {
      title: t('诉讼主体 '),
      dataIndex: 'hjdssyydjSsztyg',
      key: 'a.hjdssyydj_ssztyg',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('订单号'),
      dataIndex: 'hjdssyydjDdh',
      key: 'a.hjdssyydj_ddh',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('客户姓名'),
      dataIndex: 'hjdssyydjKhxm',
      key: 'a.hjdssyydj_khxm',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('身份证号'),
      dataIndex: 'hjdssyydjSfzh',
      key: 'a.hjdssyydj_sfzh',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('手机号'),
      dataIndex: 'hjdssyydjSjh',
      key: 'a.hjdssyydj_sjh',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('省份'),
      dataIndex: 'hjdssyydjSf',
      key: 'a.hjdssyydj_sf',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('身份证地址'),
      dataIndex: 'hjdssyydjSfzdz',
      key: 'a.hjdssyydj_sfzdz',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('剩余本金'),
      dataIndex: 'hjdssyydjSybj',
      key: 'a.hjdssyydj_sybj',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('诉请金额'),
      dataIndex: 'hjdssyydjSqje',
      key: 'a.hjdssyydj_sqje',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('管辖法院'),
      dataIndex: 'hjdssyydjGxfy',
      key: 'a.hjdssyydj_gxfy',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('提交日期'),
      dataIndex: 'hjdssyydjTjrq',
      key: 'a.hjdssyydj_tjrq',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('微法院状态'),
      dataIndex: 'hjdssyydjWfyzt',
      key: 'a.hjdssyydj_wfyzt',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('法院审批意见'),
      dataIndex: 'hjdssyydjFyspyj',
      key: 'a.hjdssyydj_fyspyj',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('法院审核 意见归类'),
      dataIndex: 'hjdssyydjFyshyjgl',
      key: 'a.hjdssyydj_fyshyjgl',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('法院案件沟通情况'),
      dataIndex: 'hjdssyydjFyajgtqk',
      key: 'a.hjdssyydj_fyajgtqk',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('立案方式'),
      dataIndex: 'hjdssyydjLafs',
      key: 'a.hjdssyydj_lafs',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('材料是否邮寄'),
      dataIndex: 'hjdssyydjClsfyj',
      key: 'a.hjdssyydj_clsfyj',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('单号'),
      dataIndex: 'hjdssyydjDh',
      key: 'a.hjdssyydj_dh',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('邮寄时间'),
      dataIndex: 'hjdssyydjYjsj',
      key: 'a.hjdssyydj_yjsj',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('法院电话'),
      dataIndex: 'hjdssyydjFydh',
      key: 'a.hjdssyydj_fydh',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('案件当前状态'),
      dataIndex: 'hjdssyydjAjdqzt',
      key: 'a.hjdssyydj_ajdqzt',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('法院跟进记录'),
      dataIndex: 'hjdssyydjFygjjl',
      key: 'a.hjdssyydj_fygjjl',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('被告手机号状态'),
      dataIndex: 'hjdssyydjBgsjhzt',
      key: 'a.hjdssyydj_bgsjhzt',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('还款意向'),
      dataIndex: 'hjdssyydjHkyx',
      key: 'a.hjdssyydj_hkyx',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('被告跟进记录'),
      dataIndex: 'hjdssyydjBggjjl',
      key: 'a.hjdssyydj_bggjjl',
      sorter: true,
      width: 130,
      align: 'left',
    },
    {
      title: t('案件负责人'),
      dataIndex: 'hjdssyydjAjfzr',
      key: 'a.hjdssyydj_ajfzr',
      sorter: true,
      width: 130,
      align: 'left',
    },
  ];

  const actionColumn: BasicColumn = {
    width: 160,
    actions: (record: Recordable) => [
      {
        icon: 'i-clarity:note-edit-line',
        title: t('编辑户籍地诉讼运营登记'),
        onClick: handleForm.bind(this, { id: record.id }),
        auth: 'operating:ftdsHjdssyydj:edit',
      },
      {
        icon: 'i-ant-design:delete-outlined',
        color: 'error',
        title: t('删除户籍地诉讼运营登记'),
        popConfirm: {
          title: t('是否确认删除户籍地诉讼运营登记'),
          confirm: handleDelete.bind(this, record),
        },
        auth: 'operating:ftdsHjdssyydj:edit',
      },
    ],
  };

  const [registerDrawer, { openDrawer }] = useDrawer();
  const [registerTable, { reload, getForm }] = useTable({
    api: ftdsHjdssyydjListData,
    beforeFetch: (params) => {
      return params;
    },
    columns: tableColumns,
    actionColumn: actionColumn,
    formConfig: searchForm,
    showTableSetting: true,
    useSearchForm: true,
    canResize: true,
  });

  function handleForm(record: Recordable) {
    openDrawer(true, record);
  }

  async function handleExport() {
    const { ctxAdminPath } = useGlobSetting();
    downloadByUrl({
      url: ctxAdminPath + '/operating/ftdsHjdssyydj/exportData',
      params: getForm().getFieldsValue(),
    });
  }

  const [registerImportModal, { openModal: importModal }] = useModal();

  function handleImport() {
    importModal(true, {});
  }

  async function handleDelete(record: Recordable) {
    const params = { id: record.id };
    const res = await ftdsHjdssyydjDelete(params);
    showMessage(res.message);
    handleSuccess(record);
  }

  function handleSuccess(record: Recordable) {
    reload({ record });
  }
</script>
